package com.weijian.dal.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 路线类型枚举
 */
@Getter
public enum RouteType {
    WEST_SEA_ROUTE(1, "西海路新通道"),

    YANGTZE_RIVER_ECONOMIC_BELT(2, "长江经济带"),

    CROSS_BORDER_HIGHWAY(3, "跨境公路");

    @EnumValue
    private final int code;
    @JsonValue
    private final String description;

    RouteType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取路线类型
     *
     * @param code 编码
     * @return 路线类型
     */
    public static RouteType fromCode(int code) {
        for (RouteType type : RouteType.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }
}